package com.home.manager.utils;

import com.home.manager.exception.ApplicationError;
import org.springframework.util.StringUtils;

import java.util.Base64;

public class Decoded {

    /**
     * 验签
     *
     * @param source
     * @return
     */
    public static String base64(String source) {
        if (!StringUtils.hasText(source)) {
            return source;
        }
        try {
            // 将Base64编码的字符串转换回字节数组
            byte[] decodedBytes = Base64.getDecoder().decode(source);
            return new String(decodedBytes);
        } catch (Exception e) {
            throw new ApplicationError("");
        }
    }

    public static void main(String[] args) {
        String s = base64("123435");
        System.out.println(s);
    }


}
